#!/bin/sh
echo "环境安装中...."
./init.sh
echo "环境安装完成...."
arch=$(uname -m)
if [ -z $mode ];then
	echo "没检测到环境变量。"
else
	arch=$arch"_high"
	echo $arch
fi
/usr/node/$arch/ttnode -p /mnts -i /usr/node/uid.txt -d -L /usr/node/$arch/ttnode.lock1
sleep 2
uid=$(cat /usr/node/uid.txt)
echo $uid
qrencode -m 1 -t ANSI $uid
echo -e "\n************甜糖app扫此码绑定设备,填写邀请码123463支持作者*************"
echo -e "********************欢迎加入QQ交流群：970772910********************\n"
echo -e "####################################################################################"
./getPort.sh &
while true 
do
d=`date '+%F %T'`;
num=`ps fax | grep 'ttnode' | egrep -v 'grep|echo|rpm|moni|guard' | wc -l`;
if [ $num -lt 1 ];then

 echo "[$d] ttnode is dead...restarting" >> /mnts/ttnodeLog.log 
 echo "[$d] ttnode is dead...restarting"
 /usr/node/$arch/ttnode -p /mnts -i /usr/node/uid.txt -d -L /usr/node/$arch/ttnode.lock1
 sleep 5
fi
sleep 10
done